package com.sunplus.common.core.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sunplus.common.core.domain.BaseEntity;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * 用户对象
 */
public class SysUser extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 用户名
     */
    private String UserID;

    /**
     * 部门ID
     */
    private String DepartmentID_SelSource;

    /**
     * 真实姓名
     */
    private String UserName;

    /**
     * 用户等级[0.非会员|1.一级会员|2.二级会员|3.三级会员]
     */
    private String Level_Sel;

    /**
     * 用户类型 [0.系统管理员|1.服务人员|2.普通会员3，s手机用户]
     */
    private String UserType_Sel;

    /**
     * 用户邮箱
     */
    private String Email;

    /**
     * 手机号码
     */
    private String Mobile;

    /**
     * 是否已注册im
     */
    private String IsRegisterIM;

    /**
     * 用户头像
     */
    private String Photo_Upload;

    /**
     * 密码
     */
    private String PassWord;

    /**
     * 盐加密
     */
    private String salt;

    /**
     * 帐号状态（0.启用|1.停用）
     */
    private String State_Sel;

    /**
     * 店铺ID
     */
    private String StoreID;

    /**
     * 供应商ID
     */
    private String SupplierID;

    /**
     * 最后登录时间
     */
    private Date LastLoginTime;

    /**
     * 部门对象
     */
    private SysDept dept;

    /**
     * 角色对象
     */
    private List<SysRole> roles;

    /**
     * 角色组
     */
    private String[] roleIds;

    /**
     * 岗位组
     */
    private String[] postIds;

    private String openID;

    private String nickName;

    public String getOpenID() {
        return openID;
    }

    public void setOpenID(String openID) {
        this.openID = openID;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getWechatImage() {
        return wechatImage;
    }

    public void setWechatImage(String wechatImage) {
        this.wechatImage = wechatImage;
    }

    private String wechatImage;


    public SysUser() {

    }

    public SysUser(String userId) {
        this.UserID = userId;
    }

    @NotBlank(message = "用户名不能为空")
    public String getUserID() {
        return UserID;
    }

    public void setUserID(String userID) {
        UserID = userID;
    }

    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return UserName;
    }

    public void setUserName(String userName) {
        UserName = userName;
    }

    @JsonIgnore
    @JsonProperty
    public String getPassWord() {
        return PassWord;
    }

    public void setPassWord(String passWord) {
        PassWord = passWord;
    }

    public boolean isAdmin() {
        return isAdmin(this.UserType_Sel);
    }

    public static boolean isAdmin(String userType_Sel) {
        return "0".equals(userType_Sel);
    }

    public String getDepartmentID_SelSource() {
        return DepartmentID_SelSource;
    }

    public void setDepartmentID_SelSource(String departmentID_SelSource) {
        DepartmentID_SelSource = departmentID_SelSource;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return Email;
    }

    public void setEmail(String email) {
        Email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getMobile() {
        return Mobile;
    }

    public void setMobile(String mobile) {
        Mobile = mobile;
    }

    public String getLevel_Sel() {
        return Level_Sel;
    }

    public void setLevel_Sel(String level_Sel) {
        Level_Sel = level_Sel;
    }

    public String getUserType_Sel() {
        return UserType_Sel;
    }

    public void setUserType_Sel(String userType_Sel) {
        UserType_Sel = userType_Sel;
    }

    public String getIsRegisterIM() {
        return IsRegisterIM;
    }

    public void setIsRegisterIM(String isRegisterIM) {
        IsRegisterIM = isRegisterIM;
    }

    public String getPhoto_Upload() {
        return Photo_Upload;
    }

    public void setPhoto_Upload(String photo_Upload) {
        Photo_Upload = photo_Upload;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getState_Sel() {
        return State_Sel;
    }

    public void setState_Sel(String state_Sel) {
        State_Sel = state_Sel;
    }

    public String getStoreID() {
        return StoreID;
    }

    public void setStoreID(String storeID) {
        StoreID = storeID;
    }

    public String getSupplierID() {
        return SupplierID;
    }

    public void setSupplierID(String supplierID) {
        SupplierID = supplierID;
    }

    public Date getLastLoginTime() {
        return LastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        LastLoginTime = lastLoginTime;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public String[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String[] roleIds) {
        this.roleIds = roleIds;
    }

    public String[] getPostIds() {
        return postIds;
    }

    public void setPostIds(String[] postIds) {
        this.postIds = postIds;
    }

}
